/*    

    bobbietalk - a visual programming environment for toy robotics

    Copyright (C) 2013  Roberto Tiella

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/
package bobbietalk.simulator;

import bobbietalk.simulator.sensors.Sensor;

/**
 *
 * @author roberto
 */
public abstract class AbstractRobot {

    private int hits = 0;
    private int numSensors = 0;
//    BranchGroup shape;
//    BranchGroup body;
    public static final int MAX_SENSOR_NUMBER = 36;
    private Sensor[] sensors = new Sensor[MAX_SENSOR_NUMBER];

    public AbstractRobot() {
    }

    public int addSensor(Sensor s) {
        int nsens = numSensors;
        sensors[numSensors] = s;
        numSensors++;
        return nsens;
    }

    public int getNumSensors() {
        return numSensors;
    }

    public Sensor[] getSensors() {
        return sensors;
    }

    public int getSensorValue(int i) {
        return sensors[i].getRawValue();
    }

    public Sensor getSensor(int i) {
        return sensors[i];
    }

    public void setSensorsVisibility(boolean v) {
        for (int i = 0; i < numSensors; i++) {
            sensors[i].setVisibility(v);
        }
    }

    public abstract void addObserver(RobotObserver obs);

    public void setSensorsActive(boolean v) {

        System.out.println("******** Sensors");

        for (int k = 0; k < numSensors; k++) {
            sensors[k].setActive(v);
        }
    }

    abstract public void setPlatformActive(boolean v);

    abstract public double getX();

    abstract public double getY();

    abstract public double getAngle();

    public abstract void setDt(double d);
}
